package com.goldstone.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.dbb.util.StringUtils;

@Entity
@Table
public class Tag extends AuditableEntity {
	String name;
	Long browTimes;
	
	public Tag() { }
	
	public Tag(String name) {
		this.name = name; 
	}
	@Transient
	public static List<Tag> getTags(String tagsString) {
		List<Tag> tags = new ArrayList<Tag>();
		if(tagsString == null || tagsString.trim().length() == 0)
			return tags;
		List<String> names = StringUtils.getUnitListString(tagsString, ",", " ", "，");
		for(String name : names) {
			tags.add(new Tag(name));
		}
		return tags;
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Long getBrowTimes() {
		return browTimes;
	}
	public void setBrowTimes(Long browTimes) {
		this.browTimes = browTimes;
	}
	
	
}
